About .faces (formerly .triangles) files

Faces files are UTF8 text files consisting of lines of coordinates that can be used to construct geometric objects using OpenGL's GL_TRIANGLES and/or GL_QUADS.  The .faces format extends the more basic .triangles file.

--------------------------------------
.triangles

Each line has three vertex/normal pairs with each vertex and normal having x,y,z values.  Each line must have a total of 18 floating point numbers seperated by commas followed by a newline.

Each line looks like this in pseudo code:

v[0].x, v[0].y, v[0].z, n[0].x, n[0].y, n[0].z, v[1].x, v[1].y, v[1].z, n[1].x, n[1].y, n[1].z, v[2].x, v[2].y, v[2].z, n[2].x, n[2].y, n[2].z \n

Adding the triangles to OpenGL's current context looks something like this:

GLfloat n [numTriangles, 3];	//normal array
GLfloat v [numTriangles, 3];	//vertex array

glBegin(GL_TRIANGLES);

	int n;
	int i;
	for (n=0; n<numTriangles; n++) {
		for (i=0; i<3; i++) {
			glNormal3f(n[n,i].x], n[n,i].y], n[n,i].z]);
			glVertex3f(v[n,i].x], v[n,i].y], v[n,i].z]);
		}
	}

glEnd();

--------------------------------------
.faces

This is an expanded format that describes triangular or quad faces, face colors, and allows comments.  Both triangle face and quad face lines start with a "TF" or "QF" field and include a single normal for the entire 3D face.  Color can be changed with a Face Color line, values are 0.0 to 1.0.

Each line looks like this in pseudo code:

triangle face TF
TF, v[0].x, v[0].y, v[0].z, v[1].x, v[1].y, v[1].z, v[2].x, v[2].y, v[2].z, n.x, n.y, n.z \n

quad face QF
QF, v[0].x, v[0].y, v[0].z, v[1].x, v[1].y, v[1].z, v[2].x, v[2].y, v[2].z, v[3].x, v[3].y, v[3].z, n.x, n.y, n.z \n

face color FC
   FC, red, green, blue, alpha \n

comment #
   #Lines that begin with # are ignored as comments \n

